<?php

namespace App\Console\Commands\Renew;

use App\Service\Renew\RenewOrderService;
use Illuminate\Console\Command;
use Illuminate\Validation\ValidationException;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;

class GenerateRenewUserContractCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'renew:generateRenewUserContract {orderNo} {workflowNo} {contractStartDateTime?} {contractEndDateTime?}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '这家伙又忘记改命令的注释了';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     * @throws ValidationException
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function handle(): int
    {
        $orderNo               = $this->input->getArgument("orderNo");
        $workflowNo            = $this->input->getArgument("workflowNo");
        $contractStartDateTime = $this->input->getArgument("contractStartDateTime") ?? "";
        $contractEndDateTime   = $this->input->getArgument("contractEndDateTime") ?? "";


        RenewOrderService::generateRenewUserContract(
            $orderNo,
            $workflowNo,
            $contractStartDateTime,
            $contractEndDateTime
        );

        return 0;
    }
}
